package com.atguigu.yygh.hosp.controller;

import java.text.ParseException;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.atguigu.yygh.common.result.Result;
import com.atguigu.yygh.hosp.service.ScheduleService;
import com.atguigu.yygh.model.hosp.Schedule;

import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/admin/hosp/schedule")
//@CrossOrigin  //允许跨域访问
public class ScheController {

	@Autowired
	private ScheduleService scheduleService;
	
	//根据医院编号   科室编号 查询排班规则数据
	@ApiOperation(value = "查询排班规则数据")
	@GetMapping("/getScheduleRule/{page}/{limit}/{hostcode}/{depcode}")
	public Result getScheduleRule(@PathVariable(value = "page") Integer page,
                                  @PathVariable(value = "limit") Integer limit,
                                  @PathVariable(value = "hostcode") String hostcode,
                                  @PathVariable(value = "depcode") String depcode){
		Map<String,Object> scheduleMap = scheduleService.getRule(page, limit, hostcode, depcode);
		return Result.ok(scheduleMap);
		
	}
	
	//根据医院编号   科室编号 工作日期   查询排班详细信息
	@ApiOperation(value = "查询排班详细")
	@GetMapping("/getScheduleList/{hostcode}/{depcode}/{workDate}")
	public Result getScheduleList( @PathVariable(value = "hostcode") String hostcode,
                                  @PathVariable(value = "depcode") String depcode,
                                  @PathVariable(value = "workDate") String workDate) throws ParseException{
		List<Schedule> scheduleList = scheduleService.getDetailList(hostcode, depcode, workDate);
		return Result.ok(scheduleList);
	}
}
